<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
request.setAttribute("ctx", path);
String errorInfo = (String)request.getAttribute("errorInfo");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    <title>用户登录</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">
	<script type = "text/javascript" ></script>
		<script src="js/jquery.js"></script>
	<link href = "${ctx}/css/login.css " type = "text/css" rel = "stylesheet">
  </head>
 	<script type="text/javascript">
		function reimg(){
			var imgTag = document.getElementById("imgCode");
			var now = new Date();
			imgTag.src = "/COneClient/ImageServlet?time="+now.getTime();
		}
	
	</script>
  <body>
  	<div class = "up" >
  		<div class = "center">
  		<div class = "login">
  			<form action="${pageContext.request.contextPath}/LoginServlet" method="post">
  			<div>
  				<table>
  					 <tr>
           				<td height="80" align="left"></td>
         			 </tr>
  					<tr height = "35" align = "center">
  						<td align = "center">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;用户名：</td>
  						<td><input type = "text" name = "username"></input></td>
  					</tr>
  					<tr height = "35">
  						<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;密&nbsp;码：</td>
  						<td><input type = "password" name = "password"></input></td>
  					</tr>
  					<tr >
  						<table >
  							<tr>
  								<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;验证码：</td>
  								<td ><input  style="width:60px;"type = "text" name = "code"></input></td>
  								<td name = "code">
  									<img id ="imgCode" src ="${pageContext.request.contextPath}/ImageServlet"/>
  									<a href ="#" onclick = "reimg()">看不清，换一张</a>
  								</td>
  							</tr>
  							<tr>
  								<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
  							</tr>
  							<tr>
  							<%
  							if(errorInfo!=null){
  							%>
  							<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
  							<td><%=errorInfo %></td>	
  							<%
  							}
  							%>
  							
  								
  							</tr>
  						</table>
  						
  					</tr>
  				</table>
  				</div>
  				<div align = "center" height = "35">
  					<input type = "submit" value = "登&nbsp;录"></input>
  				</div>
  			</form>
  		</div>
  			<!--  
  			<table>
  				<tr>
  				<td></td>
  				<td><div class = "login"></div></td>
  				</tr>
  			</table>
  			-->
  		</div>
  	</div>
  	<div class = "down"  >
  	</div>
  <!--  
    <form action="${pageContext.request.contextPath}/LoginServlet" method="post">
    	
    	<div>
    		用户名：<input type="text" name="username" value=""/>
    	</div>
    	<div>
    		密码：<input type="password" name="password" value=""/>
    	</div>
    	<div>
    		验证码：<input type = "text" name = "code" />
    		<img id ="imgCode" src ="${pageContext.request.contextPath}/ImageServlet"/>
    		<input type = "button"  name ="changeCode" value ="换一换" onclick = "changeCode()"> 
    	</div>
    	<input type = "submit" value = "登录" >
    </form>
    -->
  </body>
  <script type="text/javascript">
  
	//function changeCode(){
		//var imgCodeObj = $("#imgCode") ;
		//var src = imgCodeObj.attr("src");
		//imgCodeObj.attr("src",src);
		//alert(src);
	
	//}
	//时间戳     
	//为了使每次生成图片不一致，即不让浏览器读缓存，所以需要加上时间戳     
	/*
	function chgUrl(){
		Date date = new Date();
		var url = request.getContextPath +"?date="+date.toString();
		return url;
	}  
	*/
</script>
</html>

